from flask import render_template
from flask_login import current_user

from apps.models.gift import Gift
from apps.view_models.book import BookViewModel
from . import web


__author__ = '七月'


@web.route('/')
def index():
    books = []
    if current_user.is_authenticated:
        recent_gifts = Gift.recent(uid=current_user.id)
        books = [BookViewModel(gift.book) for gift in recent_gifts]
    return render_template('index.html', recent=books)


@web.route('/personal')
def personal_center():
    pass
